﻿@using e_TicaretSistemi.Models
@{
    var sales = (IList<Sale>)ViewBag.BasketSales;
    var basketProducts = (IList<Product>)ViewBag.BasketProducts;
}

@if (sales != null && sales.Count > 0)
{
    <h3 style="height: 25px; border-bottom: 1px solid #f3f3f3;">
        Satın Aldıklarım
    </h3>

    <table class="sale-productList" style="clear: both">
        <th>Ürün No</th>
        <th>Ürün Başlığı</th>
        <th>Fiyatı</th>
        <th>Satış Durumu</th>
        <th>Son İşlem Tarihi</th>
        <th>Fatura Adresi</th>
        <th>Teslimat Adresi</th>
        @foreach (var item in sales)
        {
            <tr>
                <td>
                    @item.Product.Id
                </td>
                <td>
                    @item.Product.Title
                </td>
                <td>
                    @(((item.Product.Kdv * item.Product.Price) / 100) + item.Product.Price) TL
                </td>
                <td>
                    @{
            if (item.SaleState == (short)Enums.SaleState.PendingCheck)
            {
                <abbr>Onay Bekliyor.</abbr>
            }
            else if (item.SaleState == (short)Enums.SaleState.PendingDelivery)
            {
                <abbr>Kargoda Bekliyor.</abbr>
            }
            else if (item.SaleState == (short)Enums.SaleState.Complated)
            {
                <abbr>Satış Tamamlandır.</abbr>
            }
            else if (item.SaleState == (short)Enums.SaleState.Cancel)
            {
                <abbr>Satış İptal Edildi.</abbr>
            }
                    }
                </td>
                <td>
                    @(item.LastUpdateDate ?? item.RecordDate)
                </td>
                <td>
                    @item.BillAdress
                </td>
                <td>
                    @item.DeliveryAdress
                </td>
            </tr>
        }
    </table>
}

@if (basketProducts != null && basketProducts.Count > 0)
{
    <h3 style="height: 25px; border-bottom: 1px solid #f3f3f3;">
        Sepetim
    </h3>

    <div class="tab-content" style="display: block; float: left;">
        <div class="items" style="width: 745px !important;">
            <div class="cl">&nbsp;</div>
            <ul>

                @foreach (var product in ((IList<Product>)(ViewBag.BasketProducts)))
                {
                    <li>
                        <h3>@product.Title</h3>
                        <div class="image">
                            <a href="@Url.Action("Detail", "Product", new {id = product.SeoText})">
                                <img src="@product.ImageUrl" alt="@product.Title" style="height: 126px;" />
                            </a>
                        </div>
                        <p>
                            Ürün No: <span>@product.Id</span><br />
                            Boyut Listesi: <span>@product.Attributes</span><br />
                            Marka Adı: <span>@product.Model</span><br />
                            <a href="@Url.Action("Sale", "Product", new { id = product.Id })">Satın Al   -   </a>
                            <a href="@Url.Action("RemoveBasket", "Customers", new {id = product.Id})">Sepeten Çıkar</a>
                        </p>
                        <p class="price">Ürün Fiyatı: <strong>@(((product.Price * product.Kdv) / 100) + product.Price) TL</strong> </p>
                        <a href="@Url.Action("Detail", "Product", new {id = product.SeoText})" class="detail">Detaylı İncele</a>
                    </li>
                }
            </ul>
            <div class="cl">&nbsp;</div>
        </div>
    </div>
}